#!groovy
node {
    stage('checkout') {
        checkout scm
    }

    def javaHome = tool('jdk1.8')
    def mvnHome = tool('mvn3')
    env.PATH = "${mvnHome}/bin:${env.PATH}"

    try {
        stage('mvn-test-package') {
            sh "JAVA_HOME=${javaHome} mvn test jacoco:report findbugs:findbugs"
        }
    }
    catch (exc) {
        echo 'I failed'
    }
    finally {
        junit "target/surefire-reports/*.xml"
        jacoco classPattern: "target/classes", execPattern: "target/**.exec", sourcePattern: "src/main/java"
        findbugs canComputeNew: false, defaultEncoding: "", excludePattern: "", healthy: "", includePattern: "",
                pattern: "target/findbugsXml.xml", unHealthy: ""

    }

}